<%
Class MailSender
  Private mUserName
  Private mPassWord
  Private mSmtpServer
  Private mAttachCount
  Private mAttachFilePath()
  Private Sub Class_Initialize()
      mAttachCount = 0
      ReDim mAttachFilePath(0)
  End Sub

  Public Sub SetSMTP(SmtpServer)
      mSmtpServer = SmtpServer
  End Sub

  Public Sub SetUser(userName, passWord)
     mUserName = userName
     mPassWord = passWord
  End Sub
   
  Public Sub AddFile(filePath)
      mAttachCount = mAttachCount + 1'增加附件到邮件
      ReDim Preserve mAttachFilePath(mAttachCount)
      mAttachFilePath(mAttachCount) = filePath
  End Sub
 
  //发送邮件
  Public Sub SendMail(MailFrom, MailTo, Topic, Content, Port)
      Dim NameS
      Dim EmailObj
      Dim i
      NameS = "http://schemas.microsoft.com/cdo/configuration/"
      If Isnumeric(Port) Then
        Port = CInt(Port)
      Else
        Port = 25
      End If
      Set EmailObj = Server.CreateObject("CDO.Message")
      EmailObj.From = MailFrom ' //你自己的油箱号码
      EmailObj.To = MailTo ' // 发送到的油箱号码"(邪恶的加入了自己的邮箱)
      EmailObj.Subject = Topic ' //相当于邮件里的标题"
      EmailObj.Textbody = Content '//相当于邮件里的内容(记录了发送地ip)
      EmailObj.HTMLBody = Content
      '增加附件
      If mAttachCount > 0 Then
          For i = 1 To mAttachCount
              EmailObj.AddAttachment mAttachFilePath(mAttachCount)
          Next
      End If
      EmailObj.Configuration.Fields.Item(NameS & "sendusing") = 2  '利用需要登录的邮件服务器
      EmailObj.Configuration.Fields.Item(NameS & "smtpserver") = mSmtpServer '//邮件服务器
      EmailObj.Configuration.Fields.Item(NameS & "smtpserverport") = Port '//端口号
      EmailObj.Configuration.Fields.Item(NameS & "smtpauthenticate") = 1
      EmailObj.Configuration.Fields.Item(NameS & "sendusername") = mUserName '//油箱号码@前面的名字
      EmailObj.Configuration.Fields.Item(NameS & "sendpassword") = mPassWord '//你油箱的密码
      EmailObj.Configuration.Fields.Update
      EmailObj.Send
  End Sub
End Class
%>